﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace Client.Threads
{
    public enum RequestPhase{RESERVATION_ANSWER,TENTATIVELY_BOOKED, REQUEST_COMMIT, COMMIT,ABORT};

    public class Request
    {
        private String _clientId;

        private RequestPhase _requestProtocolPhase;

        private ArrayList _availableSlots;

        private bool _answer;

        private long _slotNumber;

        public Request(String clientId, ArrayList availableSlots)
        {
            _clientId = clientId;
            _requestProtocolPhase = RequestPhase.RESERVATION_ANSWER;
            _availableSlots = availableSlots;
        }

        public Request(String clientId, bool answer, long slotNumber)
        {
            _clientId = clientId;
            _requestProtocolPhase = RequestPhase.TENTATIVELY_BOOKED;
            _answer = answer;
            _slotNumber = slotNumber;
        }

        public Request(String clientId, bool answer, long slotNumber, bool doCommitRequest)
        {
            _clientId = clientId;
            _requestProtocolPhase = RequestPhase.TENTATIVELY_BOOKED;
            _answer = answer;
            _slotNumber = slotNumber;
            if (doCommitRequest)
                _requestProtocolPhase = RequestPhase.COMMIT;
            else
                _requestProtocolPhase = RequestPhase.REQUEST_COMMIT;
        }

        public Request(RequestPhase protocolPhase, long slotNumber)
        {
            _slotNumber = slotNumber;
            _requestProtocolPhase = protocolPhase;
        }

        public String ClientId
        {
            get { return _clientId; }
        }

        public RequestPhase RequestProtocolPhase
        {
            get { return _requestProtocolPhase; }
        }

        public ArrayList AvailableSlots
        {
            get { return _availableSlots; }
        }

        public bool Answer
        {
            get { return _answer; }
        }

        public long SlotNumber
        {
            get { return _slotNumber; }
        }
    }   
}
